package com.mingtai.design.pattern.creationalming.builder;

/**
 * @author: tianmingtai
 * @create: 2021/01/07 18:42
 * @description: 构建者模式
 */

public class Course {

    private String courseName;
    private String coursePPt;
    private String courseVideo;
    private String courseArticle;
    /**
     * 问答
     */
    private String courseQA;

    public Course(CourseBuilder courseBuilder) {
        this.courseName = courseBuilder.courseName;
        this.coursePPt = courseBuilder.coursePPt;
        this.courseVideo = courseBuilder.courseVideo;
        this.courseArticle = courseBuilder.courseArticle;
        this.courseQA = courseBuilder.courseQA;
    }

    @Override
    public String toString() {
        return "Course{" +
                "courseName='" + courseName + '\'' +
                ", coursePPt='" + coursePPt + '\'' +
                ", courseVideo='" + courseVideo + '\'' +
                ", courseArticle='" + courseArticle + '\'' +
                ", courseQA='" + courseQA + '\'' +
                '}';
    }

    public static class CourseBuilder {
        private String courseName;
        private String coursePPt;
        private String courseVideo;
        private String courseArticle;
        /**
         * 问答
         */
        private String courseQA;

        // 静态内部类，返回类本身
        public CourseBuilder builderCourseName(String courseName) {
            this.courseName = courseName;
            return this;
        }

        public CourseBuilder builderCoursePPt(String coursePPt) {
            this.coursePPt = coursePPt;
            return this;
        }

        public CourseBuilder builderCourseVideo(String courseVideo) {
            this.courseVideo = courseVideo;
            return this;
        }

        public CourseBuilder builderCourseArticle(String courseArticle) {
            this.courseArticle = courseArticle;
            return this;
        }

        public CourseBuilder builderCourseQA(String courseQA) {
            this.courseQA = courseQA;
            return this;
        }

        public Course build() {
            return new Course(this);
        }

    }


}
